import Nerv from "nervjs";
import Taro from "@tarojs/taro-h5";
// 所有标签都要进入
import { View, Text, Image } from '@tarojs/components';
import './index.less';
import Son from "./son";
import { tools1 } from "../../tools/index";
// 引入图片
import img from '../../static/QQ图片20200228200942.jpg';

class Fatcher extends Taro.Component {
  render() {
    const [userName, setUserName] = Taro.useState('父组件');
    const [blogTtile, setBlogTtile] = Taro.useState('');
    const [blogTtile2, setBlogTtile2] = Taro.useState('');
    // useEffect 生命函数
    Taro.useEffect(() => {
      setBlogTtile(this.$router.params.blogTtile);
      setBlogTtile2(this.$router.params.blogTtile2);
    }, []); // [] 是在页面进入时执行一次

    Taro.useEffect(() => {
      tools1();
    }, []);
    return <View>
      <Text>
      {userName}
      </Text>
      <Son fathToSon={userName}></Son>
  <View>路由接受的参数 {blogTtile}</View>
  <View>路由接受的参数2 {blogTtile2}</View>
  <View>
    {/* 不可以直接stc静态引入 因为打包后目录结构会发生变化 */}
    <Image width="100px" height="100px" src={img}></Image>

        <Image width="200px" height="200px" src={require('../../static/QQ图片20200228201001.jpg')}></Image>
  </View>
    </View>;
  }

  componentDidMount() {
    super.componentDidMount && super.componentDidMount();
  }

  componentDidShow() {
    super.componentDidShow && super.componentDidShow();
  }

  componentDidHide() {
    super.componentDidHide && super.componentDidHide();
  }

}

export default Fatcher;